package com.zzyl.nursing.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.dto.ServiceItemDto;
import com.zzyl.nursing.mapper.ServiceItemMapper;
import com.zzyl.nursing.service.ServiceItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ServiceItemServiceImpl implements ServiceItemService {


    @Autowired
    private ServiceItemMapper serviceItemMapper;
    /**
     * 分页查询所有服务项目
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public TableDataInfo<NursingProject> listPageAll(Integer pageNum, Integer pageSize) {
        Page<Object> page = PageHelper.startPage(pageNum, pageSize);
        long total = page.getTotal();
        List<NursingProject> nursingProjects = serviceItemMapper.selectList(null);
        TableDataInfo<NursingProject> np = new TableDataInfo<>();
        np.setTotal(total);
        np.setCode(200);
        np.setRows(nursingProjects);
        np.setMsg("查询成功");
        return np;
    }

    /**
     * 根据id查询服务项目
     * @param id
     * @return
     */
    @Override
    public NursingProject getById(Long id) {
        return serviceItemMapper.selectById(id);
    }
}
